package org.junv;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/CateList")
public class CateList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		PrintWriter out =  response.getWriter();
		String sql="select * from equipCategory";
		ResultSet rs=null;
		DBBean myBean = new DBBean();
		myBean.init();
		rs=myBean.executeQuery(sql);
		//将返回的信息显示到table里面。。。
		try {
			if(rs.next()){
				out.println("<table  border='1'>");
				out.println("<tr><th>类别ID</th><th>类别名</th><th>删除 </th></tr>");
				while(rs.next()){
					out.println("<tr><td>"+rs.getString("equipCategoryId")+"</td><td>"+rs.getString("equipCategoryName")+
							"</td><td><a href='DelCate?equipCategoryId="+rs.getString("equipCategoryId")+"'>delete</a></td></tr>");
					
					//out.println(rs.getString("equipCategoryId")+"....."+rs.getString("equipCategoryName"));
				}
				out.println("</table>");
			}else{
				out.print("没有可以显示的内容");
				return;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			System.out.println("Result这里出了问题。。。。");
			e.printStackTrace();
			myBean.colse();
		}
		myBean.colse();
	}
	

	

}
